
//
//  PlanViewController.m
//  Animation
//
//  Created by student on 16/3/18.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "PlanViewController.h"

@interface PlanViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation PlanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//    //UIVIew隐式动画
//    
//    //1.方式1
//    [UIView beginAnimations:nil context:nil];
//    [UIView setAnimationDuration:1];
//    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
//    [UIView setAnimationRepeatAutoreverses:YES];
//    [UIView setAnimationRepeatCount:NSNotFound];
//    
//    //中止值
//    CGPoint center = self.imageView.center;
//    center.x += 100;
//    center.y += 100;
//    self.imageView.center = center;
//    [UIView commitAnimations];
    
    //2.方式2
    [UIView animateWithDuration:NSNotFound
                          delay:0
         usingSpringWithDamping:0.01
          initialSpringVelocity:5
                        options:UIViewAnimationOptionAllowUserInteraction
                     animations:^{
                         CGPoint center = self.imageView.center;
                         center.x += 50;
                         center.y += 50;
                         self.imageView.center = center;
                     }
                     completion:^(BOOL finished) {
                         
                     }];
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
